You can choose from several methods to supply the values that a function or program uses in calculations.
This method is useful primarily for values that must be the same each time the program or function is used.
1. | Define the program. |
Define calculatearea()= Prgm w:=3 h:=23.64 area:=w*h Disp area
|
2. | Run the program. |
|
70.92 |
A program or function can refer to variables created beforehand. This method requires users to remember the variable names and to assign values to them before using the object.
1. | Define the program. |
Define calculatearea()= Prgm area:=w*h Disp area
|
2. | Supply the variables, and then run the program. |
w:=3 : h:=23.64
|
70.92 |
This method lets users pass one or more values as arguments within the expression that calls the program or function.
The following program, volcyl, calculates the volume of a cylinder. It requires the user to supply two values: height and radius of the cylinder.
1. | Define the volcyl program. |
|
2. | Run the program to display the volume of a cylinder with a height of 34 mm and a radius of 5 mm. |
|
Note: You do not have to use the parameter names when you run the volcyl program, but you must supply two arguments (as values, variables, or expressions). The first must represent the height, and the second must represent the radius.
You can use the Request and RequestStr commands in a program to make the program pause and display a dialog box prompting the user for information. This method does not require users to remember variable names or the order in which they are needed.
You cannot use the Request or RequestStr command in a function.
1. | Define the program. |
Define calculatearea()= Prgm area:=w*h
|
2. | Run the program and respond to the requests. |
calculatearea() : area Width: 3 (3 entered as a response) Height: 23.64 (23.64 entered as a response) |
70.92 |
Use RequestStr instead of Request when you want the program to interpret the user’s response as a character string rather than a math expression. This avoids requiring the user to enclose the response in quotation marks (““).